<?php

namespace app\common\service;

use yii\helpers\Url;

/**
 * 构建链接
 */
class UrlService
{
    //构建admin所有链接
    public static function buildAdminUrl($path, $params = [])
    {
        $domain_param = \yii::$app->params["domain"];
        $path = Url::toRoute(array_merge([$path], $params));
        return $domain_param["admin"] . $path;
    }

    //构建Customer所有链接
    public static function buildCustomerUrl($path, $params = [])
    {
        $domain_param = \yii::$app->params["domain"];
        $path = Url::toRoute(array_merge([$path], $params));
        return $domain_param["customer"] . $path;
    }

    //构建index所有链接
    public static function buildIndexUrl($path, $params = [])
    {
        $domain_param = \yii::$app->params["domain"];
        $path = Url::toRoute(array_merge([$path], $params));
        return $domain_param["index"] . $path;
    }

    //构建空链接
    public static function buildNullUrl()
    {
        return "javascript:void(0)";
    }

    public static function buildPicUrl($bucket, $file_key)
    {
        $domain_config = \Yii::$app->params['domain'];
        $upload_config = \Yii::$app->params['upload'];
        return $domain_config['index'] . $upload_config[$bucket] . "/" . $file_key;
    }

}
